/*
package com.tedu.weibotest.conteoller;

import com.tedu.weibotest.mapper.UserMapper;
import com.tedu.weibotest.pojo.dto.UserLoginDTO;
import com.tedu.weibotest.pojo.dto.UserRegDTO;
import com.tedu.weibotest.pojo.entity.User;
import com.tedu.weibotest.pojo.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.HttpSessionRequiredException;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@Api(tags = "用户模块")
@RestController
@RequestMapping("/v1/users")
@Slf4j
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @ApiOperation("注册功能")
    @PostMapping("/reg")

    private int reg(@RequestBody UserRegDTO userRegDTO){
        System.out.println(userRegDTO);
        String username=userRegDTO.getUsername();
        User findUser=userMapper.selectByUsername(username);
        if(findUser!=null){
            return 2;
        }
        User user=new User();
        BeanUtils.copyProperties(userRegDTO,user);
        user.setCreated(new Date());
        userMapper.insert(user);
        return 1;
    }
    @ApiOperation("登录功能")
    @PostMapping("/login")
    private int log(@RequestBody UserLoginDTO userLoginDTO , HttpSession session){
        System.out.println(userLoginDTO);
        User user=userMapper.selectByUsername(userLoginDTO.getUsername());
        if (user!=null){
            if (user.getPassword().equals(userLoginDTO.getPassword())){
                session.setAttribute("user",user);
                return 1;
            }else {
                return 2;
            }
        }else {
            return 3;
        }

    }

    @ApiOperation("获取当前用户信息")
    @GetMapping("/currentUser")
    public UserVo currentUser(HttpSession session){
        User user=(User)session.getAttribute("user");
        if (user==null){
            return null;
        }else{
            UserVo userVo=new UserVo();
            BeanUtils.copyProperties(user,userVo);
            return userVo;
        }
    }

    @ApiOperation("退出登录")
    @GetMapping("/logout")
    public void logout(HttpSession session){
        session.removeAttribute("user");
    }


}
*/
